The format Specifiers is used to control the formatting of values when they are printed or displayed as a string format. using str.format() to format the string in the proper manner . when we using string format specifiers to display the string as proper manner and some order . The python provides the more Format specifiers that is in the below
format specifiers | Description | Example | Output |
---|---|---|---|
%s | It is used to format the string value in the python code | str="coder" print("Darshan is %s " %str) |
Darshan is coder |
%d | It is used to format the integer in the python code | int=24 print("Ur age : %d" %intr) |
Ur age 24 |
%f | It is used to formatting float value | a=500.00 print("Your Salary : %f"%a) |
Your Salary : 500.00000 |
%e | It is used to format thr exponent value in the python code that is fractional value. | x=1000 print("the value is %e"%x) |
the value is 1.000000e+03 |
%o | It is used to format the octal value in the python code | x=8 print(" The Octal value is :%o"%x) |
The octal value is :10 |
%g | It is used to format the general value in the python code | x=20 print("The value is %g"%x) |
The value is 209 |
%c | it is used to format the individual character in the python code | x='A' print("%c"%x) |
A |